<input type="hidden" name="reply_id" value="{$reply['id']}" />
<div class="alert alert-block alert-new">
	<a class="close" data-dismiss="alert">×</a>
	<h4 class="alert-heading">添加摇一摇活动</h4>
	<table>
		<tbody>
				{if $reply['status']}
					<a id="jinyong" href="{php echo create_url('index/module', array('do' => 'status', 'name' => 'yyy','rid' => $reply['rid'], 'status' => 0))}" onclick="return ajaxopen(this.href)" class="btn btn-primary module-button-switch">禁用</a>
				{else}
					<a id="qiyong" href="{php echo create_url('index/module', array('do' => 'status', 'name' => 'yyy','rid' => $reply['rid'], 'status' => 1))}" onclick="return ajaxopen(this.href);" class="btn btn-danger module-button-switch">启用</a>
				{/if}			
			<tr>
				<th><a href="{php echo create_url('index/module', array('do' => 'yyy', 'name' => 'yyy', 'id' => $reply['rid']))}">刮奖地址</a></th>
				<td><a href="{php echo create_url('index/module', array('do' => 'list', 'name' => 'yyy', 'id' => $reply['rid']))}">查看中奖名单</a>
				    <a href="{php echo create_url('index/module', array('do' => 'showtime', 'name' => 'yyy', 'id' => $reply['rid']))}" target="_blank">展示页面</a></td>
			</tr>
			<tr>
				<th>项目标题</th>
				<td><input type="text" name="title" value="{$reply['title']}"> </td>
			</tr>
			<tr>
				<th>活动时间</th>
				<th><span>从</span>&nbsp;&nbsp;<input type="text" name="start_time" value="{$reply['start_time']}" style="width:130px;" onfocus="WdatePicker({dateFmt:'yyyy-M-d H:mm:ss'})">&nbsp;&nbsp;<span>到</span>&nbsp;&nbsp;<input type="text" name="end_time" value="{$reply['end_time']}" style="width:130px;" onfocus="WdatePicker({dateFmt:'yyyy-M-d H:mm:ss'})"></th>
			</tr>
			<tr>
				<th>活动图片</th>
				<td>
					<div id="" class="uneditable-input reply-edit-cover">
						<div class="detail">
							<span class="pull-right">大图片建议尺寸：640像素 * 320像素</span>
							<input type="button" id="egg-picture" fieldname="picture{$namesuffix}" class="btn btn-mini reply-edit-cover-upload" value="<i class='icon-upload-alt'></i> 上传" style="" />
							<button type="button" class="btn btn-mini reply-news-edit-cover-remove" id="upload-delete" onclick="doDeleteItemImage(this, 'yyy-picture-value')" style="{if empty($reply['picture'])} display:none;{/if}"><i class="icon-remove"></i> 删除</button>
						</div>
						{if !empty($reply['picture'])}
						<input type="hidden" name="picture-old" value="{$reply['picture']}">
						<div id="upload-file-view" class="upload-view">
							<input type="hidden" id="yyy-picture-value" value="{$reply[picture]}">
							<img width="100" src="{$_W['attachurl']}{$reply['picture']}">&nbsp;&nbsp;
						</div>
						{else}
						<div id="upload-file-view"></div>
						{/if}
					</div>
				</td>
			</tr>
			<tr>
				<th>活动结束图片</th>
				<td>
					<div id="" class="uneditable-input reply-edit-cover">
						<div class="detail">
							<span class="pull-right">大图片建议尺寸：640像素 * 320像素</span>
							<input type="button" id="egg-picture2" fieldname="picture_end{$namesuffix}" class="btn btn-mini reply-edit-cover-upload" value="<i class='icon-upload-alt'></i> 上传" style="" />							
							<button type="button" class="btn btn-mini reply-news-edit-cover-remove" id="upload-delete2" onclick="my_doDeleteItemImage(this, 'egg-picture2-value','upload-file-view2')" style="{if empty($reply['end_picture'])} display:none;{/if}"><i class="icon-remove"></i> 删除</button>
						</div>
						{if !empty($reply['end_picture'])}
						<input type="hidden" name="picture2-old" value="{$reply['end_picture']}">
						<div id="upload-file-view2" class="upload-view">
							<input type="hidden" id="egg-picture2-value" value="{$reply['end_picture']}">
							<img width="100" src="{$_W['attachurl']}{$reply['end_picture']}">&nbsp;&nbsp;
						</div>
						{else}
						<div id="upload-file-view2"></div>
						{/if}
					</div>
				</td>
			</tr>
			<tr>
				<th>活动简介</th>
				<td>
					<textarea  style="height:150px;" name="description" class="span7" cols="60">{$reply['description']}</textarea>
					<div class="help-block">用于图文显示的简介</div>
				</td>
			</tr>
			<tr>
				<th>活动规则</th>
				<td>
					<textarea id="rule" style="height:150px;" name="rule" class="span7" cols="60">{$reply['rule']}</textarea>
					<div class="help-block">活动的相关说明和活动奖品介绍。</div>
				</td>
			</tr>
			<tr>
				<th>提前倒计时</th>
				<td>
					<input type="text" value="{$reply['countdown']}" class="span7" name="countdown" />
					<div class="help-block">活动开始倒计时（秒）。</div>
				</td>
			</tr>
		</tbody>
	</table>
	<div id="append-list" class="list">
	{if !empty($award)}
		{php $prize = 1;}
		{loop $award $item}
		<div class="item" id="egg-item-{$item['id']}">
		{php include $this->template('yyy/item');}
		</div>
		{php $prize++;}
		{/loop}
	{/if}
	</div>
</div>
<script type="text/javascript" src="http://www.my97.net/DP/My97DatePicker/WdatePicker.js"></script>
<script type="text/html" id="yyy-form-html">
{php unset($item); include $this->template('yyy/item');}
</script>
<script type="text/javascript">
$('#qiyong, #jinyong').click(function () {
	setTimeout("history.go(0)",500);
});	
kindeditor($('#rule'));
kindeditorUploadBtn($('#egg-picture'));
my_kindeditorUploadBtn($('#egg-picture2'),'upload-file-view2','upload-delete2');
function my_kindeditorUploadBtn(obj,upload_file_view,upload_delete) {
	if (typeof KindEditor == 'undefined') {
		$.getScript('./resource/script/kindeditor/kindeditor-min.js', initUploader);
	} else {
		initUploader();
	}
	function initUploader() {
		var uploadbutton = KindEditor.uploadbutton({
			button : obj,
			fieldName : 'imgFile',
			url : './index.php?act=attachment&do=upload',
			width : 100,
			afterUpload : function(data) {
				if (data.error === 0) {
					var url = KindEditor.formatUrl(data.url, 'absolute');
					$(uploadbutton.div.parent().parent()[0]).find('#'+upload_file_view).html('<input value="'+data.filename+'" type="hidden" name="'+obj.attr('fieldname')+'" id="'+obj.attr('id')+'-value" /><img src="'+url+'" width="100" />');
					$(uploadbutton.div.parent().parent()[0]).find('#'+upload_file_view).addClass('upload-view');
					$(uploadbutton.div.parent().parent()[0]).find('#'+upload_delete).show();
				} else {
					message('上传失败，错误信息：'+data.message);
				}
			},
			afterError : function(str) {
				message('上传失败，错误信息：'+str);
			}
		});	
		uploadbutton.fileBox.change(function(e) {
			uploadbutton.submit();
		});
	}
}
function my_doDeleteItemImage(obj, id,upload_file_view) {
	var filename = $(obj).parent().parent().find('#' + id).val();
	ajaxopen('./index.php?act=attachment&do=delete&filename=' + filename, function(){
		$(obj).parent().parent().find('#'+upload_file_view).html('');
	});
	return false;
}
</script>